This invention relates generally to cache management for computer systems. More particularly, this invention relates to management of disk blocks cached in the memory of a distributed shared memory computer system. An example of such a computer system is a NUMA (non-uniform memory access) machine.
In a computer system, one of the tasks of the operating system kernel is to maintain files such as data on mass storage devices (such as disks) so that processes executing in the computer can properly access these files. For example, when a process,wants to read data from a file stored on disk, the kernel brings the data into the main memory of the computer where the process+an access it. Similarly, the kernel often writes data in main memory back to disk to save the data.
The kernel could read and write directly to and from the disk for all file system accesses, but system response time and throughput would be poor because disk access times are quite slow. The kernel therefore attempts to minimize the frequency of disk access by keeping a pool of internal data buffers in main memory, called the buffer cache. A typical buffer cache and its management are described in The Design of the UNIX Operating System, by Maurice J. Bach (Prentice-Hall 1986), which is incorporated by reference herein and summarized below. Traditional UNIX systems, for example, use a dedicated area in memory called the block buffer cache to cache blocks accessed through the file system; the virtual memory system caches process text and data pages separately. Modern UNIX systems integrate the buffer cache within the virtual memory system.
When reading blocks of data from disk, the kernel attempts to read first from the buffer cache. If the data is already in the cache, the kernel does not have to read from disk. If the data is not in the cache, however, the kernel reads the data from disk and caches it, using an algorithm that tries to save as much good data in the cache as possible. Similarly, the kernel caches data that it writes to disk so that the data is available in memory if the kernel later tries to read it.
During system initialization, the kernel allocates space for a number of buffers, configurable according to memory size and system performance constraints. A buffer consists of two parts: a data array of memory that contains data blocks from disk and a buffer header that identifies a particular data array. Because there is a one-to-one mapping of buffer headers to data arrays, both parts are often referred to in the art as a xe2x80x9cbuffer.xe2x80x9d The context of a particular reference should make clear which part is being discussed. The data in a buffer corresponds to the data in a logical disk block in a file, and the kernel identifies a buffer""s contents by examining fields in the buffer header. The buffer is the in memory copy of the disk block; the contents of the disk block map into the buffer, but the mapping is temporary and exists only until the kernel decides to map another disk block into that particular buffer.
The buffer header contains a number of fields and pointers that provide information about the buffer and its contents. Several fields uniquely identify the buffer such as by the file system and block number of the data on disk. Another field gives the status of the buffer such as locked, valid, etc. A pointer points to the associated memory array that stores the data. The buffer header also contains two sets of pointers used by buffer allocation algorithms to maintain the overall structure of the buffer pool.
One of these sets of pointers relates to a free list of buffers maintained by the kernel. Data is cached in the buffer pool according to a least recently used algorithm. After the kernel allocates a buffer to a disk block, it cannot use the buffer for another block until all other buffers have been used more recently. The free list preserves the least recently used order. The free list is typically implemented as a circular, doubly linked list of buffer headers with a dummy buffer header that marks its beginning and end; the forward and backward pointers in the header link the buffer to the list. Every buffer is put on the free list when the system is booted. The kernel normally removes a buffer from the head of the free list when it needs to allocate a buffer for a disk block and places a buffer at the tail of the free list when the buffer is available for allocation. Hence, the buffers that are closer to the head of the free list have not been used as recently as those that are further from the head.
The other set of pointers is used for efficient searching of the buffer pool for a particular buffer. Rather than simply group all of the buffers into the buffer pool, the kernel organizes the buffers into separate queues, hashed as a function of a disk block attribute such as its address (e.g., file and block offset). The kernel links the buffers on a hash queue into a circular, doubly linked list using the forward and backward pointers in the set. A hashing function is chosen that uniformly distributes the buffers across the set of hash queues, such as a modulo function.
FIG. 1 shows a cache management data structure (also known as buffer cache metadata) that includes headers of the hash queues on the left side and associated rows of buffer headers for each hash queue on the right side. The queue headers are also known as xe2x80x9cbucketsxe2x80x9d and the queues as xe2x80x9cchainsxe2x80x9d or xe2x80x9clistsxe2x80x9d of buffer header elements. With a hashing function of modulo 4, all buffers whose disk block numbers are multiple of 4 are elements of the first hash queue, buffers whose disk block numbers have a remainder of 1 are elements of the second hash queue, etc. FIG. 1 also shows how the free list is implemented through the doubly linked list. Buffer 3 is at the head of the free list and buffer 10 is at the tail.
In a traditional implementation each buffer in the buffer cache exists on a hash queue. A buffer may also be on the free list if its status is free. Because a buffer may be simultaneously on a hash queue and on the free list, the kernel has two ways to find it. It searches the hash queue if it is looking for a particular buffer, and it removes a buffer from the free list if it needs a buffer for storing a disk block.
Although buffer caches were initially used in operating systems, they are not limited to such. They also find use in application programs including database management systems (DBMS) or database servers. These servers manage large databases of information (data) such as product information, employee information, or airline reservations. DBMSs are often configured as a client/server model with a database of information and a database server as the back end and inexpensive desktop computers as front ends, or clients. The client runs user-friendly applications that enable a user to communicate with the database server. User requests to a database server are called queries.
In a database the information is physically stored in several files but is logically organized into tables of related data such as employees, products, etc. A table consists of a set of rows and columns. A column represents a category of data, such as Employee Name, while a row represents specific instances of those categoriesxe2x80x94for example, all of the data for one employee. A table is a logical area of storage made up of data segments that are allocated by the database server for storing table data. For example, in an employee table, the data segment stores such information as the names of the employees, their hire dates, and so forth. A data segment, in turn, is made up of data blocks. A data block is the smallest logical unit of storage. A data block consists of row data (the actual data contained in rows or parts of rows of a table), free space (space that can be used for adding new rows), and block information (block attribute, applicable table, and other header information). Though a data block is a logical structure, it corresponds to a certain number of bytes of physical disk space. This related physical space is a disk block. The terms data block and disk block are often used interchangeably.
In many cases a database of interest is a massive object occupying thousands of billions of bytes (terabytes) of data, only a small portion of which can be stored in the main memory of the computer system at any time. The permanent copy of the database is stored on secondary storage such as a disk. In response to user queries the database server stores requested disk blocks in a disk block buffer cache. FIG. 2 shows how a disk block buffer cache is used in a particular database server, the Oracle Server from Oracle Corporation of Redwood Shores, California. The database buffer cache shown there is a region of main memory that stores the buffers as well as the buffer cache metadata (e.g., hash queue headers and buffer headers). This particular database server has two lists: an LRU list and a dirty list, which together are equivalent in function to the free list described above. The database writer (DBWR) is a process responsible for writing modified data from buffers in the cache (listed on the dirty list) to data files on disk. If a buffer on the LRU list has modified data, it is not overwritten but is first moved to the dirty list. Once the DBWR copies the modified data on the dirty list to the data files, the buffers on that list are free for use.
This caching of disk blocks, of course, reduces the number of times data must be read from the disk, an operation that is thousands of times slower that reading the data directly from main memory. A disk operation is thus avoided if a disk block required by another query is already stored in the buffer cache. For large computer systems with massive databases, the disk block buffer cache must itself be quite large. It is not uncommon to require a buffer cache of tens of billions of bytes to reduce disk 10 operations sufficiently to meet system performance requirements.
Whether used in an operating system or an application program, disk block buffers are traditionally allocated from a global pool of main memory without concern for system topology. This same allocation is true for the buffer cache metadata that keeps track of each disk block in the buffer cache. This means that the physical memory locations for the buffers in the cache and for the metadata are not necessarily contiguous, but can be anywhere within an area of memory reserved for the buffer cache.
For most computer systems the actual locations of the buffers or cache metadata is not of concern because the memory is centralized. In a uniprocessor machine, for example, there is only one physical location for main memory and all of its storage is equally accessible in time to the processor (that is, all storage has the same latency). This is also true in multiprocessor computers known as symmetric multiprocessors (SMPs), which have a single, centralized physical memory shared by all of the processors.
SMP systems, however, use a single-bus architecture that limits performance as the number of processors in the system grows beyond a certain amount. Because of its nature, a bus cannot physically connect large numbers of processors while still providing both the bandwidth capacity and memory access latency required by today""s high-speed microprocessors. Thus the benefit of a disk block buffer cache to a DBMS is no longer fully realized once an SMP system grows to the extent that its bus bandwidth begins to fall.
To overcome the limitations of SMP systems, a new multiprocessor architecture has emerged in recent years. The architecture combines a multiple of SMP nodes with a system interconnect. Each of the nodes has a limited number of processors, local memory, and remote cache interconnected thereon by a high-speed node bus. A single physical memory address space is still shared by all the processors of the computer, but the memory is distributed among the separate nodes. Computers built with this architecture are called distributed shared memory machines and are described in a number of publications such as Computer Architecture: A Quantitative Approach, by Hennessy and Patterson (Morgan Kaufmann 1996), which is incorporated herein by reference. These computers are also known as NUMA (non-uniform memory access) machines because access to the separate physical memories by different processors is no longer uniform in time. Processors located on the same node as a local memory access the local memory faster than processors that must access that memory from across the system interconnect.
This difference in memory access times presents a problem in managing a disk block buffer cache on a NUMA machine. Recall that the cache metadata that manages the buffer cache is traditionally allocated from a global pool of main memory without concern for the system topology. Almost certainly, then, this metadata (which is accessed much more often that the buffers themselves) is stored on a number of nodes. A processor on one node, in accessing the metadata to locate, allocate, or deallocate buffers, must therefore reference memory on several remote nodes across the system interconnect. These frequent and long references to remote memories take significant time. Performance tests with NUMA machines have shown that the execution time required for cache management increases dramatically as the number of nodes increases, despite the presence of a remote cache on the processor""s node to cache metadata stored in remote memories. The remote cache simply cannot keep up with the frequent changes to the metadata stored in the remote memories, and thus is frequently out of date.
An objective of the invention, therefore, is to provide a method and means for efficiently accessing cache management data in a distributed shared memory computer system such as a NUMA machine.
In accordance with the invention, a buffer cache management structure for a distributed shared memory computer system comprises a first portion of the management structure stored in the first memory and containing a first set of management data structures for a buffer cache and a second portion of the management structure stored in the second memory and containing a second set of management data structures for a buffer cache. Each set of management data structures is stored entirely within one memory.
Further in accordance with the invention, a process may perform operations on a buffer cache management structure stored in a distributed shared memory computer system through the following actions: determining, from an attribute of a data block requested by a first process, in which memory a buffer cache management structure associated with the data block is stored; determining if the memory containing the buffer cache management structure is local to the first process if the first process is remote from the memory, having a process that is local to the memory perform the operation on the buffer cache management structure. Such a process may be a second process separate from the first process
In one embodiment of this method, the first process performs the operation on the buffer cache management structure if the memory is local to the first process.
The foregoing and other features and advantages of the invention will become more apparent from the following detailed description and drawings of an illustrated embodiment.